# class Animal:
#     name = '动物'
#     def sleep(self):
#         print('动物需要睡觉')

# 继承Animal
## 重载，当子类有和父类同名方法
# class Dog(Animal):
#     name = '狗'
#     def sleep(self):
#         print('狗需要睡觉')
#
# mydog = Dog()
# print(mydog.name)
# mydog.sleep()

# class Animal:
#
#     def __init__(self,name):
#         self.name = name
#
# class Dog(Animal):
#
#     # 重写父类方法
#     # def __init__(self,name,age):
#     #     self.name = name
#     #     self.age = age
#
#     # super()
#     def __init__(self,name,age):
#         super().__init__(name)
#         self.age = age
#
# mydog = Dog('旺财',4)
# print(mydog.name,mydog.age)

"""
多继承
继承多个父类也称为多继承
在多继承中，如果多个父类中属性名，或者方法名相同，那么将按照MRO算法查找
- 1、先在自己的类中找，找到就结束
- 2、在父类中按照顺序查找，从左到右

语法如下：
    class A:
        pass
    class B:
        pass
    class C(A,B):
        pass
"""
class Dog:
    def __init__(self,name):
        self.name = name

    def show_info(self):
        print(f'狗的名字叫{self.name}')

    def run(self):
        print('狗拍的快')
class Husky:
    def __init__(self,name):
        self.name = name

    def show_info(self):
        print(f'哈士奇的名字叫{self.name}')

    def run(self):
        print('哈士奇的快')

    def sofa(self):
        print('哈士奇要沙发')

class MyDog(Dog,Husky):
    def __init__(self,name,age):
        super().__init__(name)
        self.age = age

    def show_info(self):
        print(f'mydog的名字叫{self.name}')

mydog = MyDog('旺仔',4)
mydog.run()
mydog.sofa()
mydog.show_info()